package com.dongzhu1428.express.module1.rest;

import com.dongzhu1428.express.module1.Result;
import com.dongzhu1428.express.module1.dto.AddExpressParamDto;
import com.dongzhu1428.express.module1.entity.Express;
import com.dongzhu1428.express.module1.mapper.express.ExpressMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 快递模块
 */
@RestController
@RequestMapping("express")
public class ExpressController {
	@Autowired
	ExpressMapper expressMapper;

	/**
	 * 添加快递
	 * @param dto
	 * @return
	 */
	@PostMapping("addExpress")
	public Result<Integer> addExpress(@RequestBody AddExpressParamDto dto){
		Express express = Express.builder().description(dto.getDescription()).build();
		expressMapper.insert(express);
		return  Result.success(express.getId());
	}


}
